<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    body {
      width: 100%;
      height: 100%;
      background-color: black;
    }
  </style>
</head>

<body>
  <script>
    setInterval(function () {
      var rain = document.createElement("div");
      rain.style.position = "fixed";
      rain.style.height = 400 + "px";
      rain.style.width = "10px";
      rain.style.background = "white";
      rain.style.top = "0px";
      //随机位置 整个屏幕的随机位置
      rain.style.left = Math.random() * 10000 + "px";
      document.body.appendChild(rain);
      var t = 0;
      var timer = setInterval(function () {
        var height = parseInt(rain.style.top);
        t++;
        rain.style.top = height + 2 * (Math.pow(t, 2)) + "px";      // 模拟物体下落的公式
        if (parseInt(rain.style.top) >= 10000) {
          rain.remove();
        }
      }, 1)
    }, 1)

  </script>
</body>

</html>